#ifndef CPP_DESIGN_DATABASE_H
#define CPP_DESIGN_DATABASE_H

#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>

class Database {
private:
    QSqlDatabase database;
    QSqlQuery query;

    // 数据库的实例
    static Database *instance;

public:
    static Database *getInstance();

    void connectDatabase(const QString &dbFilename = "./library.db", const QString &connName = "library");
    void openDatabase();
    void closeDatabase();
    bool isDatabaseOpen();
    bool exec(const QString &queryString);
    QSqlQuery *getQuery();
};


#endif //CPP_DESIGN_DATABASE_H
